package com.javabasic.algorithm.leetcode;

/**
 * @Author xiongmin
 * @Description //TODO
 * @Date 2020/2/8 22:21
 * @Version 1.0
 **/
public class LengthOfLastWord {
    public int lengthOfLastWord(String s) {
        if (s == null || s.isEmpty()) return 0;
        s = s.trim();
        if (s == null || s.isEmpty()) return 0;
        int index = s.lastIndexOf(" ");
        return s.substring(index+1).length();
    }
}
